<?php
	if(isset($_GET['logout']) && $_GET['logout'] == 1)
	{
		session_start();
		unset($_SESSION['login']);
		unset($_SESSION['admin']);
		unset($_SESSION['username']);
		unset($_SESSION['userid']);
		unset($_SESSION['style']);
		unset($_SESSION['background']);
		session_destroy();	
	}	
	else
		session_start();
	
	include('./php/functions.php');
	include('./config/site_config.php');
	//error_reporting(E_ALL); 
	error_reporting(0); 
?>

<html>
	<head>
		<title>MyBook+</title>
		<link rel="icon" href="./favicon.ico" type="image/x-icon" /> 
		<meta name="description" content="Das beste Social Network der Welt" content="text/html; utf-8"/>
		<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
		<?php
			//Set Background
			if (isset($_SESSION['background']))
			{
				echo '<style> 
						body{ background: url("./bg/'.$_SESSION['background'].'.png"); } 
					</style>';
			}
			else
			{
				if (isset($_SESSION['style']) && $_SESSION['style'] == 1)
				{
					echo '<style> 
							body{ background: #e1e1e1; }
						</style>';
				}
				else
				{
					echo '<style> 
							body{ background: url("./bg/1.png"); }
						</style>';
				}
			}
			//Prüft, ob und welchen Style der User ausgewählt hat (Funktioniert erst nach dem Login)
			if (isset($_SESSION['style']) && $_SESSION['style'] == 1)
				echo '<link href="CSS/style_light.css" type="text/css" rel="stylesheet" />';
			else 
				echo '<link href="CSS/style.css" type="text/css" rel="stylesheet" />';
		?>
	</head>
	<body>
		<div id="page">	
<?php
			if(isset($_SESSION['login']) && $_SESSION['login'] == 1)
			{				
				include("navbar.php");
				include("content.php");
			}
			else
			{
				include("login.php");
			}
?>
		</div>
	</body>
</html>